﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace FileCopy
{
    public partial class f_EditFilterForm : Form
    {
        private f_Directory destDirectory;
        public f_EditFilterForm(f_Directory dir)
        {
            InitializeComponent();
            destDirectory = dir;
        }

        private void f_EditFilterForm_Load(object sender, EventArgs e)
        {
            if (destDirectory.Filters != null)
            {
                for (int index = 0; index < destDirectory.Filters.Length; index++)
                {
                    textBoxMain.AppendText(string.Format("{0}\n", destDirectory.Filters[index].FilterWord));
                }
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            List<f_Filter> filters = new List<f_Filter>();
            for (int index = 0; index < textBoxMain.Lines.Length; index++)
            {
                string val = textBoxMain.Lines[index];
                if (!string.IsNullOrEmpty(val))
                    filters.Add(new f_Filter(val));
            }
            this.destDirectory.Filters = filters.ToArray();
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }
    }
}
